<template>
  <div>
    <el-table
      ref="customerTable"
      :data="tableData"
      stripe
      style="width: 100%"
      @selection-change="getSelectVal"
    >
      <el-table-column type="selection" width="55" align="center">
      </el-table-column>
      <el-table-column prop="orderNumber" label="单据编号"></el-table-column>
      <el-table-column prop="materialCode" label="物料编码"></el-table-column>
      <el-table-column prop="materialName" label="物料名称"></el-table-column>
      <el-table-column prop="applyTime" label="采购日期"> </el-table-column>
      <el-table-column prop="number" label="数量"> </el-table-column>
      <el-table-column prop="purchaseUnit" label="采购单位"> </el-table-column>
      <el-table-column prop="supplierName" label="供应商名称">
      </el-table-column>
      <el-table-column prop="totalTaxPrice" label="价税总计"> </el-table-column>
      <el-table-column prop="isGiveaway" label="是否赠品">
        <template slot-scope="scope">
          <span v-if="!scope.row.isGiveaway">否</span>
          <span v-if="scope.row.isGiveaway">是</span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="pagination"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { getOrderList } from "@/api/system/purchase";
export default {
  data() {
    return {
      tableData: [],
      currentPage: 1, //当前页
      pageSize: 10, //每页条数
      total: 0,
      rowList: [],
    };
  },
  methods: {
    //分页器size
    handleSizeChange(val) {
      this.pageSize = val;
      this.getDataList();
    },
    //分页器当前页
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getDataList();
    },
    getSelectVal(val) {
      this.$emit("update:visible", false);
      this.$emit("getSelectVal", val);
    },
    getDataList() {
      getOrderList({
        page: this.currentPage,
        limit: this.pageSize,
      }).then((res) => {
        this.tableData = res.data.records;
      });
    },
  },
  mounted() {
    this.getDataList();
  },
};
</script>

<style></style>
